<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.Date, java.util.Vector, FachadaInterfaz.Receptor" %>
<%@page import="java.util.Date, CapaLogica.*" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


<style>
</style>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta name="author" content="Luka Cvrk (www.solucija.com)" />
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="images/style.css" type="text/css" />
        <link rel="stylesheet" href="epoch/epoch_styles.css" type="text/css" />
        <title>SAST -- Consultas [Admin - Nivel 0]</title>
        <script type="text/javascript" src="epoch/epoch_classes.js"></script>
        <script type="text/javascript">
/*You can also place this code in a separate file and link to it like epoch_classes.js*/
	var bas_cal,dp_cal,ms_cal;      
        window.onload = function () {
	dp_cal1  = new Epoch('epoch_popup','popup',document.getElementById('MyDate'));
        dp_cal2  = new Epoch('epoch_popup','popup',document.getElementById('MyDate2'));  
        };
</script>
<SCRIPT LANGUAGE="JavaScript">
function enableDate(date)
{
document.busqueda_avanzada.MyDate.disabled=false
}
</SCRIPT>
        <style type="text/css">
            <!--
.Estilo2 {
	font-size: medium;
	font-weight: bold;
}
.Estilo3 {
	color: #FF0000;
	font-weight: bold;
}
.Estilo5 {color: #94523C}
-->
        </style>
    </head>
    <body>
        <% UsuarioServidor usr = (UsuarioServidor) session.getAttribute("usr_logged");
        if (usr != null) {
        %>
        <div class="content">            
            <div class="header">
                <div class="top_info">
                    <div class="top_info_right">
                        <p>
                        <table>
                            <tr>
                                <td>
                                    <!--<strong>[Sesion con nivel 0] - </strong> -->
                                </td>
                                <td>
                                    <form action="Receptor" method="POST">
                                        <span align="right">
                                            <button id="button01" name="button01" type="submit" style="font: 0.8em Tahoma, sans-serif;"> Cerrar Sesi&oacute;n </button>
                                        </span>
                                        <input type="hidden" id="tipo" name="tipo" value="salir" />
                                    </form>
                                </td>
                            </tr>
                        </table>
                    </div>	
                    <div class="top_info_left">
                        <p><b>
                                <%=new Date()%>
                            </b>
                            <br />
                            Revise las <a href="#">&uacute;ltimas solicitudes.</a>
                        </p>
                    </div>
                </div>
                <div class="logo">
                    <h1><a href="#" title="Centralized Internet Services"><span class="dark">SAST</span></a></h1>
                </div>
            </div>
            
            <div class="bar">
                <ul>
                    <li><a href="index.jsp">Inicio</a></li>
                    <li class="active">Consultas</li>
                    <li><a href="solicitudes.jsp" accesskey="s">Solicitudes</a></li>
                    <li><a href="secciones.jsp">Secciones</a></li>
                    <li><a href="servicios.jsp" accesskey="v">Servicios</a></li>
                    <li><a href="ingresar_datos_recurso.jsp" accesskey="e">Recursos</a></li>
                    <li><a href="cola.jsp" accesskey="l">Colas</a></li>
                    <li><a href="ingresar_datos_usuario.jsp" accesskey="u">Usuarios</a></li>
                    <li><a href="perfil.jsp" accesskey="l">Perfiles</a></li>
                    <li><a href="administracion.jsp">Administracion</a></li>
                </ul>
            </div>
            <div class="search_field">
                <form method="post" action="Receptor" name="busqueda">
                    <div class="search_form">
                        <p>Buscar solicitud: 
                            <input type="text" name="clave_busqueda" id="clave_busqueda" class="search" />
                            <input type="submit" value="Buscar" class="submit" />
                            <input type="hidden" value="buscar_solicitudes" id="tipo" name="tipo" />
                            <a class="grey" href="#">Avanzada</a>
                        </p>
                    </div>
                </form>
                
                <p class="bold" >
                    <% 
                    out.print("Bienvenido, " + usr.getNombre());
                    %>
                </p>
            </div>
            
            <div class="left">
            <h3>Configurar consulta:<br /></h3>
            <div class="left_box">
            <form action="Receptor" method="post" id="busqueda_avanzada" name="busqueda_avanzada">
            <table width="502" border="0">
                <div class="right_articles"><b>Buscar por: </b></div>
                <tr>
                    <td  align=center></td>
                    <td colspan="2" align=left><input type=checkbox name="recurso" value="0"><b>Recurso</b></td>
                    
                    <td colspan="3" align=left><input type=checkbox name="servicio" value="0"><b>Servicio</b></td>
                </tr>
                <tr>
                    <td  align=center></td>
                    <td colspan="2" align=left><input type=checkbox name="usuario" value="0"><b>Usuario</b></td>
                    
                    <td colspan="3" align=left><input type=checkbox name="descripcion" value="0"><b>Descripci&oacute;n</b></td>
                </tr>
                <tr>
                    <td  align=center></td>
                    <td colspan="2" align=left><input type=checkbox name="ci_solicitante" value="0"><b>C.I. Solicitante</b></td>
                    
                    <td colspan="3" align=left><input type=checkbox name="nombre_solicitante" value="0"><b>Nombre Solicitante</b></td>
                </tr>
                <tr>
                    <td colspan="5">&nbsp;</td>
            </tr>
                <tr>
                    <td colspan="5"><div class="right_articles"><b>Refinar por: </b></div></td>
            </tr>
                <tr>
                    <td width="75" align=right><b>Prioridad: </b></td>
                    <td colspan="2"><label></label><label>
                    <select name="prioridades" id="prioridades" STYLE="width: 147px;">
                        <option value ="-1">Todas</option>
                        <%  Vector v = FachadaDatos.Consultas.prioridades();    /* ATENCION: Aqui no debe llamarse a una clase de FachadaDatos */
                            if (v == null) {
                        %>
                        <option value ="-1"> Error de conexi&oacute;n. </option>
                        <%  } else { %>
                        <%      while (!v.isEmpty()) {
                                    Prioridad p = (Prioridad) v.remove(0);
                                    String name = p.getNombre();
                                        int maxLength = 30;                                         
                                        if (maxLength > name.length()) maxLength = name.length();
                        %>
                        <option value="<%= p.getId() %>"> <%= name.substring(0, maxLength) %> </option>
                        <%      }                                    
                            }
                            v = null;
                        %>
                    </select>
                    </label></td>
                    <td width="95" align=right><b>Tipo Solicitante: </b></td>
                    <td width="155"><label>
                        <select name="soltipos" id="soltipos" STYLE="width: 147px;">
                            <option value ="-1">Todos</option>
                            <%  v = new Vector();
                                v = FachadaDatos.Consultas.tiposSolicitante();    /* ATENCION: Aqui no debe llamarse a una clase de FachadaDatos */
                                if (v == null) { %>
                            <option value ="-1"> Error de conexi&oacute;n. </option>
                            <%  } else { %>
                            <%      while (!v.isEmpty()) {
                                        TipoSolicitante ts = (TipoSolicitante) v.remove(0);
                                        String name = ts.getNombre();
                                        int maxLength = 30;                                         
                                        if (maxLength > name.length()) maxLength = name.length(); %>
                            <option value="<%= ts.getId() %>" 
                            <%          if (session.getAttribute("tipo_solicitante") != null ) { 
                                            String tmp = (String)session.getAttribute("tipo_solicitante");
                                            int tmp1 = Integer.parseInt(tmp);
                                            if ( ts.getId() == tmp1 ) {
                            %> selected
                            <%              } 
                                        } %>  
                            > 
                            <%= name.substring(0, maxLength) %> </option>
                            <%      }                                 
                                }
                                v = null;
                            %>
                        </select>
                        </label></td>                   
              </tr>
                <tr>
                    <td align=right><b>Estado: </b></td>
                    <td colspan="2" ><select name="estados" id="estados" STYLE="width: 147px;">
                        <option value ="-1">Todos</option>
                        <% 
                            v = new Vector();
                            v = Receptor.obtenerEstados();    /* ATENCION: Aqui no debe llamarse a una clase de FachadaDatos */
                                if (v == null) { %>
                        <option value ="-1"> Error de conexi&oacute;n. </option>
                        <%      } else { %>
                        <%          while (!v.isEmpty()) {
                                        Estado e = (Estado) v.remove(0);
                                        String name = e.getNombre();
                                        int maxLength = 30;                                        
                                        if (maxLength > name.length()) maxLength = name.length(); %>
                      <option name="idServicio" value="<%= e.getId() %>"> <%= name.substring(0, maxLength) %> </option>
                      <%        }                                    
                                }
                                v = null;
                      %>
                    </select></td>                    
                     <td  align=right><b>Secci&oacute;n: </b></td>
                    <td ><label></label><label>
                        <select name="secciones" id="secciones" 
                        STYLE="width: 147px;">
                            <option value ="-1">Todos</option>
                            <% 
                                v = new Vector();
                                v = Receptor.secciones();
                                if (v == null) { %>
                            <option value ="-1"> Error de conexi&oacute;n con la BD. </option>
                            <%  } else { %>
                            <%      while (!v.isEmpty()) {
                                    Seccion sec = (Seccion) v.remove(0);
                                    String name = sec.getNombre();
                                    int maxLength = 50;                                    
                                    if (maxLength > name.length()) maxLength = name.length(); %>
                            <option value="<%= sec.getId() %>"> <%= name.substring(0, maxLength) %> </option>
                            <%      }                                
                                }
                                v = null;
                            %>
                     `  </select></label>                    </td>
                </tr> 
                
                <tr>
                    <td align=right><b>Fecha: </b></td>
                    <td width="25" ><div align="right">De:</div></td>
                    <td width="118" ><input type=text id="MyDate" name="MyDate" size=8 >
                      <a href="JavaScript:;" onclick="dp_cal1.toggle();">Insertar</a> </td>
                  <td  align=right></td>
                    <td ><label>
                       </td>
                </tr>
                <tr>
                    <td align=right></td>
                    <td width="25"> <div align="right">A: </div></td>
                  <td><INPUT type=TEXT id="MyDate2" name="MyDate2" size=8 >
                      <a href="JavaScript:;" onclick="dp_cal2.toggle();">Insertar</a> </td>
                    <td>&nbsp;</td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td colspan=1 align=right><b>B&uacute;squeda: </b></td>                    
                    <td colspan=2 ><input type=text size=30 name=clave id=clave></td>
                    <td colspan="2" >
                      <div align="right">
                        <input type="submit" value="Buscar" class="submit" />
                        <input type="hidden" value="busqueda_avanzada" id="tipo" name="tipo" />
                        <input type="reset" name="button" id="button" value="Limpiar" class="submit" />
                    </div></td>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td></td>
                    <td colspan="2"></td>
                    <td colspan=2 align=right></td>
                </tr>      
            </table>
            </form>
        <TABLE bgColor=#ffffff border=1 cellPadding=0 cellSpacing=3 id=calendar style="DISPLAY: none; POSITION: absolute; Z-INDEX: 4">
            <TBODY>
            <TR>
                <TD colSpan=7 vAlign=center>
                    <!-- Month combo box -->
                    <SELECT id=month onchange=newCalendar()> 
                    <SCRIPT language=JavaScript>
                    // Output months into the document.
                    // Select current month.
                    for (var intLoop = 0; intLoop < months.length; intLoop++)
                            document.write("<OPTION " +	(today.month == intLoop ? "Selected" : "") + ">" + months[intLoop]);
                    </SCRIPT>
                    </SELECT> 
                    <!-- Year combo box -->
                    <SELECT id=year onchange=newCalendar()> 
                    <SCRIPT language=JavaScript>
                    // Output years into the document.
                    // Select current year.
                    for (var intLoop = 1900; intLoop < 2028; intLoop++)
                            document.write("<OPTION " + (today.year == intLoop ? "Selected" : "") + ">" + intLoop);
                    </SCRIPT>
                    </SELECT> 
                </TD>
            </TR>
            <TR class=days>
                <!-- Generate column for each day. -->
                <SCRIPT language=JavaScript>
                // Output days.
                for (var intLoop = 0; intLoop < days.length; intLoop++)
                    document.write("<TD>" + days[intLoop] + "</TD>");
                </SCRIPT>
            </TR>
            <TBODY class=dates id=dayList onclick="getDate('')" vAlign=center>
                <!-- Generate grid for individual days. -->
                <SCRIPT language=JavaScript>
                for (var intWeeks = 0; intWeeks < 6; intWeeks++)
                {
                    document.write("<TR>");
                    for (var intDays = 0; intDays < days.length; intDays++)
			document.write("<TD></TD>");
                    document.write("</TR>");
                }
                </SCRIPT>

                <!-- Generate today day. --></TBODY>
            <TBODY>
            <TR>
                <TD class=today colSpan=5 id=todayday onclick=getTodayDay()></TD>
                <TD align=right colSpan=2><A href="javascript:HideCalendar();">
                    <SPAN style="COLOR: black; FONT-SIZE: 10px"><B>Esconder</B></SPAN></A></TD>
            </TR>
            </TBODY>

        </TABLE>                 
                
        </div>                
        </div>                
        
        <div class="right">
            <h3>Solicitudes:</h3>
            <div class="right_articles">
            <p><b><a href="ingresar_datos_solicitud.jsp">Ingresar nueva</a></b></p>
            </div>
            <div class="right_articles">
                <p><b><a href="modificar_solicitud.jsp">Modificar</a></b></p>
            </div>
            <div class="right_articles">
                <p><b><a href="redireccionar_solicitud.jsp">Redireccionar</a></b></p>
            </div>
            <div class="right_articles">
                <p><b><a href="asignar_solicitud.jsp">Asignar</a></b></p>
            </div>
            <div class="right_articles">
                <p><b><a href="finalizar_solicitud.jsp">Finalizar</a></b></p>
            </div>
            <div class="right_articles">
                <p><b><a href="cerrar_solicitud.jsp">Cerrar</a></b></p>
            </div>
            <div class="right_articles">
                <p><strong><a href="eliminar_solicitud.jsp">Eliminar</a></strong></p>
            </div>
            <div class="right_articles">
                <p><strong><a href="reabrir_solicitud.jsp">Reabrir</a></strong></p>
            </div>
            
        </div>	
        <div class="footer">
            <p><a href="#">Imprimir</a> | <a href="#">Enviar correo</a> | <a href="#">Reportes</a> | <a href="#">Estad&iacute;sticas</a> <br />
            &copy; Copyright 2008 Solware</p>
        </div>
        </div>
        <%}%>
    </body>
</html>